<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>vtablewk</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="vtablewi.html" title="vtablewi" />
    <link rel="next" href="vtablewa.html" title="vtablewa" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">vtablewk</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="vtablewi.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="vtablewa.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="vtablewk"></a>
      <div class="titlepage"></div>
      <a id="IndexVtablewk" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">vtablewk</span>
        </h2>
        <p>vtablewk — 
      Write vectors (to tables -or arrays of vectors).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp167114624"></a>
        <h2>Description</h2>
        <p>
      This opcode writes vectors to tables at k-rate.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp167115856"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>vtablewk</strong></span>  kndx, kfn, ixmode, kinarg1 [, kinarg2, kinarg3 , .... , kinargN ]</pre>
      </div>
      <div class="refsect1">
        <a id="idp167117952"></a>
        <h2>Initialization</h2>
        <p><span class="emphasis"><em>ixmode</em></span> -  index data mode. The default value is 0.</p>
        <p>            == 0 index is treated as a raw table location,</p>
        <p>            == 1 index is normalized (0 to 1).</p>
      </div>
      <div class="refsect1">
        <a id="idp167120400"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kndx</em></span> - Index into f-table, either a positive number range matching the table length (<span class="emphasis"><em>ixmode</em></span> = 0) or a 0 to 1 range (<span class="emphasis"><em>ixmode</em></span> != 0).
    </p>
        <p>
      <span class="emphasis"><em>kfn</em></span> - table number
    </p>
        <p>
      <span class="emphasis"><em>kinarg1...kinargN</em></span> - input vector elements
    </p>
        <p>
      This opcode is useful in all cases in which one needs to write sets of values associated to unique indexes (for example, multi-channel samples, STFT bin frames, spectral formants, p-field based scores etc.). The number of elements of each vector (length of the vector) is determined by the number of optional arguments on the right (<span class="emphasis"><em>kinarg1</em></span>, <span class="emphasis"><em>kinarg2</em></span>, <span class="emphasis"><em>kinarg3</em></span>, ....  <span class="emphasis"><em>kinargN</em></span>).
    </p>
        <p>
      <span class="command"><strong>vtablewk</strong></span> allows also to switch the table number at k-rate (but this is possible only when vector frames of each used table have the same number of elements, otherwise unpredictable results could occurr), as well as to choose indexing style (raw or normalized, see  also <span class="emphasis"><em>ixmode</em></span> argument of <span class="emphasis"><em>table</em></span> opcode ).
    </p>
        <p>
      Notice that no wrap nor limit mode is implemented.  So, if  an index attempt to access to a zone not allocated by the table, Csound will probably crash. However this drawback can be easily avoided by using wrap or limit opcodes applied to indexes before using <span class="emphasis"><em>vtablewk</em></span>, in order to correct eventual out-of-range values.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp167130480"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the vtablewk opcode. It uses the files <a class="ulink" href="examples/vtablewk.csd" target="_top"><em class="citetitle">vtablewk.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp167132336"></a>
          <p class="title">
            <strong>Example 1034. Example of the vtablewk opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">;-ovtablewa.wav -W -b441 -B441</span>
-odac -b441 -B441
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>


<span class="ohdr">sr</span><span class="op">=</span>44100
<span class="ohdr">kr</span><span class="op">=</span>441
<span class="ohdr">ksmps</span><span class="op">=</span>100
<span class="ohdr">nchnls</span><span class="op">=</span>2

	<span class="oblock">instr</span> 1
ilen <span class="op">=</span> <span class="opc">ftlen</span>(1)

knew1 <span class="opc">oscil</span> 10000, 440, 3
knew2 <span class="opc">oscil</span> 15000, 440, 3, 0.5
kindex <span class="opc">phasor</span> 0.3
asig <span class="opc">oscil</span> 1, <span class="ohdr">sr</span><span class="op">/</span>ilen , 1
<span class="opc">vtablewk</span> kindex<span class="op">*</span>ilen, 1, 0, knew1, knew2
<span class="opc">out</span> asig,asig
	<span class="oblock">endin</span>    


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1  0 262144   -1 "beats.wav" 0 4 0
<span class="stamnt">f</span>2  0 262144   2  0
<span class="stamnt">f</span>3  0 1024  10 1

<span class="stamnt">i</span>1 0 10
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp167134256"></a>
        <h2>Credits</h2>
        <p>Written by Gabriel Maldonado.</p>
        <p>Example written by Andres Cabrera.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="vtablewi.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="vtablewa.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">vtablewi </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> vtablewa</td>
        </tr>
      </table>
    </div>
  </body>
</html>
